package com.loan.system.domain.work.domain;

import com.loan.system.create.domain.AssistPdfSearchJhBase;
import lombok.Data;

import java.math.BigDecimal;

/**
 * packageName com.loan.web.pdf.domain
 *
 * @author Sophia
 * @className JhPdfDomain
 * @description TODO
 * @date 2024/11/4
 */
@Data
public class JhPdfDomain {

    /**
     * 序号
     */
    private Integer seqNo;

    /**
     * 摘要
     */
    private String transactionSummary;

    /**
     * 币别
     */
    private String transactionCurrency;

    /**
     * 钞汇
     */
    private String transactionBanknote;

    /**
     * 交易日期
     */
    private String transactionDate;

    /**
     * 交易金额
     */
    private String transactionAmount;

    /**
     * 账户余额
     */
    private String currentAmount;

    /**
     * 交易类型
     */
    private String transactionType;

    /**
     * 交易地点/附言
     */
    private String transactionNote;

    /**
     * 对方账号与户名
     */
    private String oppositionAccount;

    private Integer transactionMoneyInt;
    private String oppositionInformation;
    private String logNo;
    private String transactionChannels;
    // 金额小数点后数字
    private String afterNum;

    public JhPdfDomain() {
    }

    public JhPdfDomain(AssistPdfSearchJhBase base, Integer seqNo, BigDecimal currentBalance) {
        this.seqNo = seqNo;
        this.transactionSummary = base.getJhBaseTransactionSummary();
        this.transactionCurrency = base.getJhBaseTransactionCurrency();
        this.transactionBanknote = base.getJhBaseTransactionBanknote();
        this.transactionAmount = base.getJhBaseTransactionType() + String.valueOf(base.getJhBaseTransactionAmount());
        this.currentAmount = String.valueOf(currentBalance);
        this.transactionType = base.getJhBaseTransactionType();
        this.transactionNote = base.getJhBaseTransactionNote();
        this.oppositionAccount = base.getJhBaseOppositionAccount();
        this.transactionMoneyInt = base.getJhBaseTransactionAmount().intValue();
        this.logNo = seqNo.toString();
        this.oppositionInformation = base.getJhBaseOppositionAccount();
        this.transactionChannels = base.getJhBaseTransactionCurrency();
        this.afterNum = (this.transactionAmount.contains(".") && this.transactionAmount.length() > 3) ? this.transactionAmount.substring(this.transactionAmount.length() - 3) : ".00";
    }

    /**
     * 获取修改并重组后的金额值
     * @return
     */
    public String getDealAmount() {
        return String.format("%s%s%s", this.getTransactionType(), this.getTransactionMoneyInt(), this.getAfterNum());
    }
}
